<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <input id="btn1" onclick="btn1()" type="button" value="全选" />
  <input id="btn1" onclick="btn2()" type="button" value="不选" />
  <input id="btn1" onclick="btn3()" type="button" value="反选" />

  <div id="checkboxDiv">
    <input type="checkbox" /><br>
    <input type="checkbox" /><br>
    <input type="checkbox" /><br>
    <input type="checkbox" /><br>
    <input type="checkbox" /><br>
    <input type="checkbox" /><br>
    <input type="checkbox" /><br>
    <input type="checkbox" /><br>
    <input type="checkbox" /><br>
    <input type="checkbox" /><br>
    <input type="checkbox" /><br>
    <input type="checkbox" /><br>
  </div>


  <script>

    function btn1() {
      let checkboxDiv = document.getElementById("checkboxDiv")
      let checkboxs = checkboxDiv.getElementsByTagName("input")
      for (let i = 0; i < checkboxs.length; i++) {
        checkboxs[i].checked = true
      }
    }

    function btn2() {
      let checkboxDiv = document.getElementById("checkboxDiv")
      let checkboxs = checkboxDiv.getElementsByTagName("input")
      for (let i = 0; i < checkboxs.length; i++) {
        checkboxs[i].checked = false
      }
    }
    function btn3() {
      let checkboxDiv = document.getElementById("checkboxDiv")
      let checkboxs = checkboxDiv.getElementsByTagName("input")
      for (let i = 0; i < checkboxs.length; i++) {
        checkboxs[i].checked = !checkboxs[i].checked
      }
    }


  </script>

</body>

</html>